﻿#If FULL_DEBUG Then
Namespace InternalDebug
    Public Structure PackedFileInternalInformation
        Public ReadOnly StartOffset As ULong
        Public ReadOnly Length As ULong
        'Public ReadOnly MD5() As Byte
        'Public ReadOnly Property PlainMD5 As String
        '    Get
        '        Dim i As Integer
        '        Dim output As New System.Text.StringBuilder(64)
        '        For i = 0 To MD5.Length - 1
        '            If MD5(i) < 16 Then
        '                output.Append("0" & Hex(MD5(i)))
        '            Else
        '                output.Append(Hex(MD5(i)))
        '            End If
        '        Next

        '        Return UCase(output.ToString())
        '    End Get
        'End Property
        Public ReadOnly MD5 As String
        Public ReadOnly Exists As Boolean

        Public Sub New(ByVal pStartOffset As ULong, ByVal pLength As ULong, ByVal pMD5 As String, ByVal pExists As Boolean)
            StartOffset = pStartOffset
            Length = pLength
            MD5 = pMD5
            Exists = pExists
        End Sub
        Public Shared Function FileNotFound() As PackedFileInternalInformation
            Return New PackedFileInternalInformation(0, 0, "", False)
        End Function
    End Structure

    Public Module PackageDebugInterface
        Public Function GetPackedFileInformation(ByRef targetEngine As Engine, ByVal filename As String) As PackedFileInternalInformation
            Try
                Dim file As PackagedFileInformationCollection
                file = targetEngine.GetFile(filename)

                Return New PackedFileInternalInformation(file._packageOffset, file._internalSize, file._md5Hash, True)
            Catch ex As Exception
                targetEngine._AddLog("[DEBUG_INTERFACE] Exception while getting file information for <" & filename & ">. ex: " & ex.Message)
                Return PackedFileInternalInformation.FileNotFound()
            End Try
        End Function
        Public Function GetPackedFileInformation(ByRef file As Arps.Utilities.PackagedFileInformationCollection) As PackedFileInternalInformation
            Return New PackedFileInternalInformation(file._packageOffset, file._internalSize, file._md5Hash, True)
        End Function
    End Module
End Namespace
#End If

